img = new Image( $this->mTitle ); if( $this->mTitle->getNamespace() == NS_IMAGE ) { if ( $this->img->exists() ) $this->showEXIFdata(); $this->openShowImage(); # No need to display noarticletext, we use our own message, output in openShowImage() if ( $this->getID() ) { Article::view(); } else { # Just need to set the right headers $wgOut->setArticleFlag( true ); $wgOut->setRobotpolicy( 'index,follow' ); $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); $wgOut->addMetaTags(); $this->viewUpdates(); } if ( $this->img->exists() ) { $this->uploadNewVersionLink(); if ( $wgUseExternalEditor && $this->img->exists() ) { $this->externalEditorLink(); } } $this->closeShowImage(); $this->imageHistory(); $this->imageLinks(); } else { Article::view(); } } function showEXIFdata() { global $wgOut , $wgShowEXIF ; if ( ! $wgShowEXIF ) return ; $file = $this->img->getImagePath () ; $per = new phpExifReader ( $file ) ; $per->processFile () ; $r = "
" . htmlspecialchars ( $k ) . " | " ; $r .= "" . htmlspecialchars ( $v ) . " | " ; $r .= "
---|
' . wfMsg( "nolinkstoimage" ) . "
\n" ); return; } $wgOut->addHTML( '' . wfMsg( 'linkstoimage' ) . "
\n' . $text . "
\n" ); $wgOut->returnToMain( false, $this->mTitle->getPrefixedText() ); } function doDeleteOldImage( $oldimage ) { global $wgOut; $name = substr( $oldimage, 15 ); $archive = wfImageArchiveDir( $name ); # Delete the image if it exists. Sometimes the file will be missing # due to manual intervention or weird sync problems; treat that # condition gracefully and continue to delete the database entry. # Also some records may end up with an empty oi_archive_name field # if the original file was missing when a new upload was made; # don't try to delete the directory then! # $targetFile = "{$archive}/{$oldimage}"; if( $oldimage != '' && file_exists( $targetFile ) && !@unlink( $targetFile ) ) { # If we actually have a file and can't delete it, throw an error. $wgOut->fileDeleteError( "{$archive}/{$oldimage}" ); } else { # Log the deletion $log = new LogPage( 'delete' ); $log->addEntry( 'delete', $this->mTitle, wfMsg('deletedrevision',$oldimage) ); } } function revert() { global $wgOut, $wgRequest, $wgUser; global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList; $oldimage = $wgRequest->getText( 'oldimage' ); if ( strlen( $oldimage ) < 16 ) { $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); return; } if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) { $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); return; } if ( wfReadOnly() ) { $wgOut->readOnlyPage(); return; } if( $wgUser->isAnon() ) { $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' ); return; } if ( ! $this->mTitle->userCanEdit() ) { $wgOut->sysopRequired(); return; } if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) { $wgOut->errorpage( 'internalerror', 'sessionfailure' ); return; } $name = substr( $oldimage, 15 ); $dest = wfImageDir( $name ); $archive = wfImageArchiveDir( $name ); $curfile = "{$dest}/{$name}"; if ( ! is_file( $curfile ) ) { $wgOut->fileNotFoundError( htmlspecialchars( $curfile ) ); return; } $oldver = wfTimestampNow() . "!{$name}"; $dbr =& wfGetDB( DB_SLAVE ); $size = $dbr->selectField( 'oldimage', 'oi_size', array( 'oi_archive_name' => $oldimage ) ); if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) { $wgOut->fileRenameError( $curfile, "${archive}/{$oldver}" ); return; } if ( ! copy( "{$archive}/{$oldimage}", $curfile ) ) { $wgOut->fileCopyError( "${archive}/{$oldimage}", $curfile ); } # Record upload and update metadata cache $img = Image::newFromName( $name ); $img->recordUpload( $oldver, wfMsg( "reverted" ) ); $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); $wgOut->setRobotpolicy( 'noindex,nofollow' ); $wgOut->addHTML( wfMsg( 'imagereverted' ) ); $descTitle = $img->getTitle(); $wgOut->returnToMain( false, $descTitle->getPrefixedText() ); } } /** * @todo document * @package MediaWiki */ class ImageHistoryList { function ImageHistoryList( &$skin ) { $this->skin =& $skin; } function beginImageHistoryList() { $s = "\n" . wfMsg( 'imghistlegend' ) . "
\n".'